import system
import server
import os


def sys_power_on():
    """
    
    """
    first_centural_ac = system.CenturalAC()
    first_server = server.Server(port=8000)
    first_server.run()
    print('tcp server started')
    first_scheduler = system.Scheduler(maxitem=3, maxtime=120, service_interval=60)
    first_database = system.DataBase()
    # 利用名为.isopen的文件判断进程是否开启
    if os.path.exists(r'.is_open'):
        raise Exception('System thread already exist!')
    is_open = open('.is_open', 'w')
    is_open.write(str(os.getpid()))
    is_open.close()


if __name__ == "__main__":
    sys_power_on()
